from base import _YamlHelper
from page import Page
from page.background_login_page import BackgroundLoginPage


class SendGoodsPage(Page):
    sendgoods_yaml = _YamlHelper().get_config_as_dict('niushop23\\page\\sendgoods.yaml')['SendGoodsPage']
    print(sendgoods_yaml)

    def sendgoods_page(self,name,pwd):
        '''后台登录账户'''
        driver = self._driver
        login_page = BackgroundLoginPage(driver)
        login_page.back_login(name,pwd)

    def get_username_text(self):
        '''获取用户名文本'''
        driver = self._driver
        user_name_text = driver.get_text(self.sendgoods_yaml['GET_USER_NAME_TEXT'])
        return user_name_text

    def get_orderslist_text(self):
        '''获取订单列表文本'''
        driver = self._driver
        orderlist_text = driver.get_text(self.sendgoods_yaml['GET_ORDER_LIST_TEXT'])
        return orderlist_text

    def get_to_order_message(self):
        '''获取订单信息文本'''
        driver = self._driver
        order_message = driver.get_text(self.sendgoods_yaml['GET_ORDER_MESSAGE_TEXT'])
        return order_message

    def get_goods_release_text(self):
        '''获取商品发布文本'''
        driver = self._driver
        release_text = driver.get_text(self.sendgoods_yaml['GOODS_SEND_TEXT'])
        return release_text


    def order_button(self):
        '''点击订单按钮'''
        driver = self._driver
        driver.click(self.sendgoods_yaml['CLICK_ORDER_BUTTON'])

    def ready_sendgoods(self):
        '''点击待发货按钮进入商品详情'''
        driver = self._driver
        driver.click(self.sendgoods_yaml['CLICK_READY_ORDER_BUTTON'])
        driver.click(self.sendgoods_yaml['CLICK_ORDER_DETAILS'])

    def sendgoods_button(self):
        '''发货按钮'''
        driver = self._driver
        driver.click(self.sendgoods_yaml['CLICK_SEND_ORDER_BUTTON'])

    def check_to_goods(self):
        '''勾选商品选择物流'''
        driver = self._driver
        driver.click(self.sendgoods_yaml['CHECK_GOODS'])
        driver.click(self.sendgoods_yaml['CLICK_LOGISTICS'])
        driver.click(self.sendgoods_yaml['CLICK_LOGISTICS_CONTENT'])
        driver.click(self.sendgoods_yaml['CLICK_TO_LOGISTICS'])
        driver.type(self.sendgoods_yaml['EXPRESS_NUMBER_WRITE'],'23333')

    def keep_good_button(self):
        '''保存按钮'''
        driver = self._driver
        driver.click(self.sendgoods_yaml['KEEP_BUTTON'])
